//
//  MJChiBaoZiHeader.m
//  MJRefreshExample
//
//  Created by MJ Lee on 15/6/12.
//  Copyright © 2015年 小码哥. All rights reserved.
//

#import "MJChiBaoZiHeader.h"
#import <UIKit/UIKit.h>
@implementation MJChiBaoZiHeader
#pragma mark - 重写方法
#pragma mark 基本设置
- (void)prepare
{
    [super prepare];
    
    // 设置普通状态的动画图片
//    NSMutableArray *idleImages = [NSMutableArray array];
//    for (NSUInteger i = 1; i<=8; i++) {
//        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"down%d.png", i]];
//        [idleImages addObject:image];
//    }
//    [self setImages:idleImages forState:MJRefreshStateIdle];
//    
//    // 设置即将刷新状态的动画图片（一松开就会刷新的状态）
//    NSMutableArray *refreshingImages = [NSMutableArray array];
//    for (NSUInteger i = 1; i<=24; i++) {
//        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"up%d.png", i]];
//        [refreshingImages addObject:image];
//    }
//    [self setImages:idleImages forState:MJRefreshStatePulling];
//    
//    // 设置正在刷新状态的动画图片
//    [self setImages:refreshingImages forState:MJRefreshStateRefreshing];
//    NSMutableArray *scaleImages = [NSMutableArray array];
//    for (NSUInteger k = 1; k<=3; k++) {
//        for (NSInteger i=1; i<=161; i++) {
//            UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"roration%d.png", i]];
//            
//            image=[self imageWithImage:imageNew scaledToSize:CGSizeMake(100, 100)];
//            [self TelescopicImageToSize:image.size];
//            
//            [scaleImages addObject:image];
//        }
//        
//    }

    
    NSMutableArray *idleImages = [NSMutableArray array];
    for (NSUInteger i = 1; i<=10; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"roration1.png"]];
        [idleImages addObject:image];
    }
    //[self setImages:idleImages forState:MJRefreshStateIdle];
    [ self setImages:idleImages duration:0.5 forState:MJRefreshStateIdle];
    // 设置即将刷新状态的动画图片（一松开就会刷新的状态）
    NSMutableArray *refreshingImages = [NSMutableArray array];
    for (NSUInteger k = 1; k<=3; k++) {
        for (NSInteger i=1; i<=161; i++) {
            UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"roration%d.png", i]];
            [refreshingImages addObject:image];
        }
    }
    //[self setImages:idleImages forState:MJRefreshStatePulling];
    [ self setImages:idleImages duration:3 forState:MJRefreshStatePulling];
    // 设置正在刷新状态的动画图片
    [self setImages:refreshingImages duration:3  forState:MJRefreshStateRefreshing];

    self.lastUpdatedTimeLabel.hidden=YES;
    self.stateLabel.hidden=YES;
}
//- (UIImage *)scaledToSize:(CGSize) size
//
//{
//    
//    UIGraphicsBeginImageContext(size);
//    
//    [self drawInRect:CGRectMake(0, 0, size.width, size.height)];
//    
//    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
//    
//    UIGraphicsEndImageContext();
//    
//    return newImage;
//    
//}
@end
